package service.impl;


import dao.RoleDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.Role;
import service.RoleService;

import java.util.List;

@Service("roleService")
public class RoleServiceImpl implements RoleService {
    //先生成一个Dao对象
    // 再通过Dao对象调用方法
    @Autowired
    private RoleDao roledao;
    @Override
    public int addRole(String dname) {
        return roledao.addRole(dname);
    }

    @Override
    public int deleteRoleById(int id) {
        return roledao.deleteRoleById(id);
    }

    @Override
    public int updateRole(Role role) {
        return roledao.updateRole(role);
    }

    @Override
    public List<Role> findAll(Role role,int offset,int pageSize) {

        List<Role> roles=roledao.findAll2(role,offset,pageSize);
        return roles;
    }


    @Override
    public Role findById(int id) {
        return roledao.findById(id);
    }

    @Override
    public boolean login(Role role) {
        if(roledao.login()>0){
            return true;
        }else{
            return false;
        }
    }

    @Override
    public int count(Role role) {
        return roledao.count(role);
    }
}
